/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.controller;

import java.util.ArrayList;
import java.util.List;
import queenb.net.entitybean.C270;
import queenb.web.store.C270Store;
import queenb.web.util.SessionProvider;
import queenb.web.util.Util;

/**
 *
 * @author Nguyen Hung
 */
public class C270Controller extends QueenbController {

    private int pc270;
    private String cv271;// City Name
    private String cv272;// abbreviation
    private int cn273;// description
    private int cn274;// description
    private int fc575;// id of country
    private C270Store c270Store;
    private boolean flagCV;
    private List<C270> c270listoftab = new ArrayList<C270>();
    //  private List<SelectItem> combolistN750 = new ArrayList<SelectItem>();
    //  private ComboboxUtil comboboxUtil;

    public C270Controller() {
        c270Store = new C270Store();
        //   comboboxUtil = new ComboboxUtil();
        Object action = getRequest().getParameter("action");
        if (action != null) {
            if (action.equals("getListC350")) {
                Object objC575 = getRequest().getParameter("fc425");
                if (objC575 != null) {
                    fc575 = Util.parseInt(objC575);
                    SessionProvider.setSessionMapValue("IDCHECKBOXFC575", fc575);
                }
                System.out.println("------FC575-----" + fc575);
            } else if (action.equals("getPc270")) {
                Object objC575 = getRequest().getParameter("pc270");
                if (objC575 != null) {
                    pc270 = Util.parseInt(objC575);
                }
                
                 Object objC5751 = getRequest().getParameter("cn274");
                if (objC5751 != null) {
                    cn274 = Util.parseInt(objC5751);
                }
                stdc_tools_updatetabc270(pc270, cn274);
                System.out.println("------PC270 aaa----" + pc270);
            }
        }
    }

    public void abc() {
        try {
            System.out.println("-----UPDATE------tham so list c270----" + pc270);

            System.out.println("----------------------THAM SO----");
        } catch (Exception e) {
        }
    }

    public void stdc_tools_updatetabc270(int PC270, int CN274) {
        try {
            System.out.println("-----UPDATE------tham so list c270----" + PC270 + CN274);
            int count = 0;

            count = c270Store.stdc_tools_updatetabc270(PC270, CN274, getLogin().getUserName());


            System.out.println("----------------------THAM SO----" + count);
        } catch (Exception e) {
        }
    }

    public List<C270> getC270listoftab() {
        try {
            System.out.println("-----------tham so list c270----" + fc575);
            if (SessionProvider.getSessionMapValue("IDCHECKBOXFC575") != null) {
                fc575 = Util.parseInt(SessionProvider.getSessionMapValue("IDCHECKBOXFC575"));
            }
            c270listoftab = c270Store.ccurpks_listoftabc270(getLogin().getModule(), getLogin().getCompanyNo(), fc575, getLogin().getUserName());
            System.out.println("-----------c270size----" + c270listoftab.size());
            return c270listoftab;

        } catch (Exception e) {
            return null;
        }

    }

    /**
     * @param c270listoftab the c270listoftab to set
     */
    public void setC270listoftab(List<C270> c270listoftab) {
        this.c270listoftab = c270listoftab;
    }

    /**
     * @return the pc270
     */
    public int getPc270() {
        return pc270;
    }

    /**
     * @param pc270 the pc270 to set
     */
    public void setPc270(int pc270) {
        this.pc270 = pc270;
    }

    /**
     * @return the cv271
     */
    public String getCv271() {
        return cv271;
    }

    /**
     * @param cv271 the cv271 to set
     */
    public void setCv271(String cv271) {
        this.cv271 = cv271;
    }

    /**
     * @return the cv272
     */
    public String getCv272() {
        return cv272;
    }

    /**
     * @param cv272 the cv272 to set
     */
    public void setCv272(String cv272) {
        this.cv272 = cv272;
    }

    /**
     * @return the cn273
     */
    public int getCn273() {
        return cn273;
    }

    /**
     * @param cn273 the cn273 to set
     */
    public void setCn273(int cn273) {
        this.cn273 = cn273;
    }

    /**
     * @return the cn274
     */
    public int getCn274() {
        return cn274;
    }

    /**
     * @param cn274 the cn274 to set
     */
    public void setCn274(int cn274) {
        this.cn274 = cn274;
    }

    /**
     * @return the fc575
     */
    public int getFc575() {
        return fc575;
    }

    /**
     * @param fc575 the fc575 to set
     */
    public void setFc575(int fc575) {
        this.fc575 = fc575;
    }

    /**
     * @return the flagCV
     */
    public boolean isFlagCV() {
        try {
            if (getC270listoftab().size() > 0) {
                System.out.println("vaooooooooooooo----------------");
                for (int i = 0; i < getC270listoftab().size(); i++) {
                    if (c270listoftab.get(i).getCn274() == 1) {
                        setFlagCV(true);
                    } else {
                        setFlagCV(false);
                    }
                }
            }
        } catch (Exception e) {
            return false;
        }
        return flagCV;

    }

    /**
     * @param flagCV the flagCV to set
     */
    public void setFlagCV(boolean flagCV) {
        this.flagCV = flagCV;
    }
}
